/**
 * Created by gongxun on 17/4/10.
 */

var KwxWaitCreateTableLayer = cc.Layer.extend({
    ctor : function (gameName) {
        this._super();

        if (gameName == "kwx" || gameName == "kwxpp"){
            var tableBgIndex = mo.fileHelper.getItem("gameKwxBgIndex_key");
            var tableBgFile = "res/ccs/table/tableBg1.png";
            if (tableBgIndex != undefined){
                tableBgFile = "res/ccs/table/tableBg" + tableBgIndex + ".png";
            }

            var spriteBg = new cc.Sprite(tableBgFile);
            spriteBg.setScale(mo.gameSize.x / spriteBg.getContentSize().width, mo.gameSize.y / spriteBg.getContentSize().height);
            this.addChild(spriteBg);

            var speiteTitle = new cc.Sprite("res/ccs/hall_second/roomCreate/waitCreateTable.png");
            this.addChild(speiteTitle);
        }else if (gameName == "nn"){

            var spriteBg = new cc.Sprite("res/ccs/nn/table_bg.png");
            spriteBg.setScale(mo.gameSize.x / spriteBg.getContentSize().width, mo.gameSize.y / spriteBg.getContentSize().height);
            this.addChild(spriteBg);

            var speiteTitle = new cc.Sprite("res/ccs/hall_second/roomCreate/waitCreateTable.png");
            this.addChild(speiteTitle);
        }else if (gameName == "gsbdx"){

            var spriteBg = new cc.Sprite("res/ccs/gsbdx/table_bg.png");
            spriteBg.setScale(mo.gameSize.x / spriteBg.getContentSize().width, mo.gameSize.y / spriteBg.getContentSize().height);
            this.addChild(spriteBg);

            var speiteTitle = new cc.Sprite("res/ccs/hall_second/roomCreate/waitCreateTable.png");
            this.addChild(speiteTitle);
        }else if (gameName == "psz"){

            var spriteBg = new cc.Sprite("res/ccs/psz/table_bg.png");
            spriteBg.setPosition(cc.p(0, (720 - mo.gameSize.y) / 2));
            this.addChild(spriteBg);

            var speiteTitle = new cc.Sprite("res/ccs/hall_second/roomCreate/waitCreateTable.png");
            this.addChild(speiteTitle);
        }else if (gameName == "whmj"){
            var spriteBg = new cc.Sprite("res/ccs/whmj/table/tableBg7.png");
            this.addChild(spriteBg);

            var speiteTitle = new cc.Sprite("res/ccs/hall_second/roomCreate/waitCreateTable.png");
            this.addChild(speiteTitle);
        }else if (gameName == "dzpk"){
            var spriteBg = new cc.Sprite("res/ccs/dzpk/playgame/game_bg.jpg");
            spriteBg.setScale(mo.gameSize.x / spriteBg.getContentSize().width, mo.gameSize.y / spriteBg.getContentSize().height);
            this.addChild(spriteBg);

            var speiteTitle = new cc.Sprite("res/ccs/hall_second/roomCreate/waitCreateTable.png");
            this.addChild(speiteTitle);
        }else if (gameName == "dtj"){
            var spriteBg = new cc.Sprite("res/ccs/dtj/table_bg.png");
            spriteBg.setScale(mo.gameSize.x / spriteBg.getContentSize().width, mo.gameSize.y / spriteBg.getContentSize().height);
            this.addChild(spriteBg);

            var speiteTitle = new cc.Sprite("res/ccs/hall_second/roomCreate/waitCreateTable.png");
            this.addChild(speiteTitle);
        }else if (gameName == "pdk"){
            var spriteBg = new cc.Sprite("res/ccs/pdk/bg.png");
            spriteBg.setScale(mo.gameSize.x / spriteBg.getContentSize().width, mo.gameSize.y / spriteBg.getContentSize().height);
            this.addChild(spriteBg);

            var speiteTitle = new cc.Sprite("res/ccs/hall_second/roomCreate/waitCreateTable.png");
            this.addChild(speiteTitle);
        }

        //坐标
        this.setPosition(cc.p(mo.curSize.x / 2, mo.curSize.y / 2));
    },

    onEnter : function(){
        this._super();

        mo.eventHelper.add("closeWaitCreateTableLayer", this, function(){
            this.removeFromParent();
        });

        this.scheduleOnce(function(){
            this.removeFromParent();
        }, 10);
    },

    onExit : function(){
        mo.eventHelper.remove(this);

        this._super();
    }
});

mo.showWaitCreateTableLayer = function(gameName){
    var kwxWaitCreateTableLayer = new KwxWaitCreateTableLayer(gameName);
    mo.sceneMainLayer.addChild(kwxWaitCreateTableLayer, 2);
};